package com.tencent.sr.iris.activity.service.localcache;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.tencent.sr.iris.activity.common.config.IrisThreadPoolConfig;
import com.tencent.sr.iris.activity.domain.event.dto.SpecialOldTttResultDTO;
import com.tencent.sr.iris.activity.repository.entity.TIrisActivityTaskDO;
import com.tencent.sr.iris.user.core.service.interfaces.dto.tutor.UserTutorRelationDTO;
import com.tencent.sr.iris.user.core.service.interfaces.dto.user.UserWideDTO;
import com.tencent.sr.iris.user.core.service.interfaces.response.activity.MemberTimeResponse;
import com.tencent.sr.iris.user.core.service.interfaces.response.activity.SpecialInviteResponse;
import com.tencent.sr.iris.user.core.service.interfaces.response.user.IrisQueryUsersInTagsResponse;

import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

/**
 * @author nixiaolin
 * @date 2023/8/18 11:40
 */
public final class LocalCacheManager {

    /**
     * 缓存用户特邀会员结果10s
     */
    public static final Cache<String, Optional<SpecialInviteResponse>> LOCALCACHE_USER_SPECIALINVITE = CacheBuilder.newBuilder()
            .concurrencyLevel(IrisThreadPoolConfig.IRIS_USER_BATCH_DATA_THREAD_COUNT)
            .expireAfterWrite(10, TimeUnit.SECONDS).initialCapacity(1000).maximumSize(1000).build();

    /**
     * 缓存用户信息
     */
    public static final Cache<String, UserWideDTO> LOCALCACHE_USER_WIDE_INFO = CacheBuilder.newBuilder()
            .concurrencyLevel(IrisThreadPoolConfig.IRIS_USER_BATCH_DATA_THREAD_COUNT)
            .expireAfterWrite(10, TimeUnit.SECONDS).initialCapacity(1000).maximumSize(1000).build();

    /**
     * 缓存查询用户等级结果
     */
    public static final Cache<String, Optional<String>> LOCALCACHE_USER_LEVELID = CacheBuilder.newBuilder()
            .concurrencyLevel(IrisThreadPoolConfig.IRIS_USER_BATCH_DATA_THREAD_COUNT)
            .expireAfterWrite(10, TimeUnit.SECONDS).initialCapacity(1000).maximumSize(1000).build();

    /**
     * 缓存查询用户升级为xx等级的时间
     */
    public static final Cache<String, MemberTimeResponse> LOCALCACHE_USER_MEMBER_TIME = CacheBuilder.newBuilder()
            .concurrencyLevel(IrisThreadPoolConfig.IRIS_USER_BATCH_DATA_THREAD_COUNT)
            .expireAfterWrite(10, TimeUnit.SECONDS).initialCapacity(1000).maximumSize(1000).build();

    /**
     * 导师缓存
     */
    public static final Cache<String, UserTutorRelationDTO> ADVISOR_CACHE = CacheBuilder.newBuilder()
            .concurrencyLevel(IrisThreadPoolConfig.IRIS_USER_BATCH_DATA_THREAD_COUNT)
            .expireAfterWrite(10, TimeUnit.SECONDS).initialCapacity(1000).maximumSize(1000).build();

    /**
     * 导师缓存
     */
    public static final Cache<String, Optional<IrisQueryUsersInTagsResponse>> USER_TAGS_CACHE = CacheBuilder.newBuilder()
            .concurrencyLevel(IrisThreadPoolConfig.IRIS_USER_BATCH_DATA_THREAD_COUNT)
            .expireAfterWrite(10, TimeUnit.SECONDS).initialCapacity(1000).maximumSize(1000).build();

    /**
     *     缓存用户见习会员时间10秒
     */
    public static final Cache<String, Optional<Long>> LOCALCACHE_USER_TRAINEETIME = CacheBuilder.newBuilder()
            .concurrencyLevel(IrisThreadPoolConfig.IRIS_USER_BATCH_DATA_THREAD_COUNT)
            .expireAfterWrite(10, TimeUnit.SECONDS).initialCapacity(2000).maximumSize(2000).build();

    /**
     *  缓存任务信息 1天
     */
    public static final Cache<String, Map<String, TIrisActivityTaskDO>> ALL_ACTIVITY_TASK_INFO = CacheBuilder.newBuilder()
            .concurrencyLevel(IrisThreadPoolConfig.IRIS_USER_BATCH_DATA_THREAD_COUNT)
            .expireAfterWrite(1, TimeUnit.DAYS).initialCapacity(1).maximumSize(1).build();

    /**
     *  老团推团信息
     */
    public static final Cache<String, Optional<SpecialOldTttResultDTO>> SPECIAL_OLD_TTT_RESULT = CacheBuilder.newBuilder()
            .concurrencyLevel(IrisThreadPoolConfig.IRIS_USER_BATCH_DATA_THREAD_COUNT)
            .expireAfterWrite(10, TimeUnit.SECONDS).initialCapacity(0).maximumSize(1000).build();
}
